<template>
<view>
<!--<import src="/we7/pages/templates/news.wxml"></import>-->
<view class="page_gap page_news">
    <text class="h1" id="newsTitle">{{newsData.sTitle}}</text>
    <view class="news_info">
        <text class="span" id="newsAuthor">{{newsData.sFrom}}</text>
        <text class="span" id="newsDate">{{newsData.time}}</text>
    </view>
    <view id="font-adjust">
        <view class="news_relative" id="newsRelative"></view>
        <view class="summary_block" id="summary">{{newsData.sDescription}}</view>
        <view class="news_txt" id="newsContent">
            <block data-type="template" data-is="newsDetail" data-attr="...newsData">
    <block v-for="(cellData, idy) in content" :key="idy">
        <view class="p" v-if="cellData.type=='view'">
            <block v-for="(item, index) in cellData.child" :key="index">
                <text @tap="stockClick" class="a" :data-seccode="item.attr['data-seccode']" :data-secname="item.attr['data-secname']" v-if="item.type=='a'">{{item.text}}</text>
                <text v-else>{{item.text}}</text>
            </block>
        </view>
        <block v-if="cellData.type=='img'">
      {{wn_html_images}}
      <image @load="imageLoad" class="img" :data-index="idy" mode="widthFix" :src="cellData.attr.src" :style="'width: ' + cellData['attr']['width'] + 'max-width: 100%height: ' + (cellData['attr']['height']?cellData['attr']['height']:auto)"></image>
        </block>
    </block>
</block>
        </view>
    </view>
</view>
</view>
</template>

<script>
var app = getApp(),
    R_htmlToWxml = require("../../resource/js/htmlToWxml.js");

export default {
  data() {
    return {
      scrollHeight: 0,
      newsData: {}
    };
  },

  components: {},
  props: {},
  onLoad: function (e) {
    this.getNewsDetail(), console.log("onLoad");
  },
  onShow: function () {
    console.log("onShow");
  },
  onReady: function () {
    console.log("onReady");
  },
  onHide: function () {
    console.log("onHide");
  },
  onUnload: function () {
    console.log("onUnload");
  },
  methods: {
    getNewsDetail: function () {
      var t = this;
      wx.request({
        url: "https://wedengta.com/wxnews/getNews?action=DiscNewsContent&type=4&id=1478677877_1406730_1_9",
        headers: {
          "Content-Type": "application/json"
        },
        success: function (e) {
          var o = e.data;

          if (0 == o.ret) {
            var n = JSON.parse(o.content);
            n.content = R_htmlToWxml.html2json(n.sContent), n.time = app.globalData.util.formatTime(1e3 * n.iTime), t.setData({
              newsData: n
            });
          } else console.log("数据拉取失败");
        },
        fail: function (e) {
          console.log("数据拉取失败");
        }
      });
    },
    stockClick: function (e) {
      var o = e.currentTarget.dataset.seccode,
          n = e.currentTarget.dataset.secname;
      console.log("stockClick:" + o + ";secName:" + n);
    }
  }
};
</script>
<style>
@import "./newsDetail.css";
</style>